var reviveCount = 5;
var mapIds = [350023100, 350023200, 350023300, 350023400, 350023500, 350023600];
var 准备地图 = 350023000;
var eventName = "黑色天堂_Act2_空袭";

function init() {
    em.setProperty("leader", "true");
    em.setProperty("state", "0");
    em.setProperty("clear", "0")
}

function setup(c, a) {
    em.setProperty("state", 1);
    em.setProperty("leader", "true");
    var c = em.newInstance(eventName);
    for (var b = 0; b < mapIds.length; b++) {
        var d = c.setInstanceMap(mapIds[b]);
        d.resetFully()
    }
    return c
}

function onPlayerRegistered(b, a) {
    var c = b.getMapInstance(0);
    a.changeMap(c, c.getPortal(0));
    b.startEventTimer(1000 * 60 * 20)
}

function onPlayerRevived(b, a) {
    return false
}

function onMonsterDamaged() {}

function onMonsterKilled(b, d) {
    var c = em.getNumberProperty("state");
    if (c == 4 && d == 8240018) {
        player.getAPI().getMap().setSpawn(false);
        player.getAPI().getMap().killAllMonsters(true);
        player.getAPI().updateInfoQuest(33132, "save=4;boss=clear;board1=Noclear");
        player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
        player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
        em.setProperty("clear", "1");
        return
    } else {
        if (c == 6 && d == 8240019) {
            player.getAPI().getMap().setSpawn(false);
            player.getAPI().getMap().killAllMonsters(true);
            player.getAPI().startQuestScript(0, 33135);
            em.setProperty("clear", "1");
            return
        }
    }
    var e = 30;
    if (c == 2) {
        var e = 40
    } else {
        if (c == 3) {
            var e = 50
        } else {
            if (c == 5) {
                var e = 60
            }
        }
    }
    var a = em.getNumberProperty("stage" + c + "_kill") + 1;
    em.setProperty("stage" + c + "_kill", a);
    b.getPlayers().forEach(function (f) {
        if (a <= e) {
            f.dropMessage(-1, "消灭数量：" + (a) + "/" + e)
        }
    });
    if (a == e) {
        em.setProperty("stage" + c, "clear");
        em.setProperty("clear", 1);
        if (c == 5) {
            player.getAPI().getMap().setSpawn(false);
            player.getAPI().getMap().killAllMonsters(true);
            player.getAPI().addPopupSay(1540454, 1000, "完全清除了!", "", 0);
            player.getAPI().updateInfoQuest(33132, "save=5;boss=clear2;board1=Noclear");
            player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear")
        } else {
            player.getAPI().fieldEffect_ScreenMsg("monsterPark/clear");
            player.getAPI().fieldEffect_PlayFieldSound("Party1/Clear", 100);
            player.getAPI().addPopupSay(1540454, 1000, "这样应该足够了。", "")
        }
    }
}

function onMapChanged(c, b, a) {
    if (mapIds.indexOf(a) < 0) {
        on玩家退场(c, b, false);
        return
    }
    em.setProperty("clear", 0);
    switch (a) {
        case 350023100:
            em.setProperty("state", 1);
            initProp("stage" + 1 + "_kill", 0);
            break;
        case 350023200:
            em.setProperty("state", 2);
            initProp("stage" + 2 + "_kill", 0);
            break;
        case 350023300:
            em.setProperty("state", 3);
            initProp("stage" + 3 + "_kill", 0);
            break;
        case 350023400:
            em.setProperty("state", 4);
            initProp("stage" + 4 + "_kill", 0);
            break;
        case 350023500:
            em.setProperty("state", 5);
            initProp("stage" + 5 + "_kill", 0);
            break;
        case 350023600:
            em.setProperty("state", 6);
            initProp("stage" + 6 + "_kill", 28);
            break
    }
}

function onPlayerDisconnected(b, a) {
    on玩家退场(b, a, false);
    return 0
}

function onTimeOut(a) {
    a.getPlayers().forEach(function (b) {
        on玩家退场(a, b, true)
    })
}

function onPlayerRevived(b, a) {
    return false
}

function onPartyDisbanded(a) {}

function onPlayerKilled(b, a) {}
var setupTask;

function openNpc(c, b, d) {
    for (var a = 0; a < c.getPlayerCount(); a++) {
        c.getPlayers().get(a).getAPI().openNpc(b, d)
    }
}

function randomNum(b, a) {
    switch (arguments.length) {
        case 1:
            return parseInt(Math.random() * b + 1, 10);
            break;
        case 2:
            return parseInt(Math.random() * (a - b + 1) + b, 10);
            break;
        default:
            return 0;
            break
    }
}

function initProp(a, b) {
    if (em.getProperty(a) == null) {
        em.setProperty(a, b)
    }
}

function initPropArray(a, d, c, e) {
    for (var b = c; b <= e; b++) {
        if (em.getProperty(a + "_" + b) == null) {
            em.setProperty(a + "_" + b, d)
        }
    }
}

function on玩家退场(c, b, a) {
    c.disposeIfPlayerBelow(a ? 999 : 0, 准备地图);
    em.getProperties().clear();
    em.setProperty("state", 0);
    em.setProperty("leader", "true");
    c.unregisterPlayer(b)
};